package com.cn.wxwinnie.java.serializable;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.Date;

import com.cn.wxwinnie.utils.PrintLine;

/**
 * @author 潇湘暮雨 E-mail:wxwinnie@hotmail.com
 * 
 * @version 创建时间：2014年3月11日 下午8:05:44
 * 
 */
public class Test {

	public static void main(String[] args) throws IOException {
		SerializableObject obj1 = new SerializableObject();
		obj1.setParam1(12345);
		obj1.setParam2("www.baidu.com");
		obj1.setParam3(new Date());

		UnSerializableObject obj2 = new UnSerializableObject();// 无法写入文件
																// java.io.NotSerializableException
		obj2.setParam1(12345);
		obj2.setParam2("www.baidu.com");
		obj2.setParam3(new Date());

		File f1 = new File("d:/test1.txt");
		FileOutputStream os1 = new FileOutputStream(f1);
		ObjectOutputStream oos1 = new ObjectOutputStream(os1);
		oos1.writeObject(obj1);
		oos1.close();
		os1.close();

		File f2 = new File("d:/test2.txt");
		FileOutputStream os2 = new FileOutputStream(f2);
		ObjectOutputStream oos2 = new ObjectOutputStream(os2);
		oos2.writeObject(obj2);
		oos2.close();
		os2.close();

		PrintLine.pringLine("操作完成");
	}

}
